
//
// 101116 - AH - Created.
// 101119 - AH - Java doc. included. But with todos.
// 101128 - AH - Renamed from ResourcePanel.
// 101219 - AH - Changes related to that Rethor output can have content from 
//               more than one Wheel spoke.
//

package org.soekrat.gui.swing.chat;

import java.awt.BorderLayout;

import javax.swing.JPanel;

import org.soekrat.engine.Soekrat2Engine;
import org.soekrat.engine.rethor.RethorAnswer;

/**
 * <p>
 *   TODO
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
@SuppressWarnings("serial")
public final class ResourceTalkPanel extends JPanel 
{
  private final ResourceTalkTablePanel m_resTable;
  
  /**
   * <p>
   *   
   * </p>
   * @param engine The engine the UI interfaces to.
   */
  public ResourceTalkPanel(Soekrat2Engine engine)
  {
    if (engine==null)
    {
      throw new NullPointerException("engine");  
    }
    
    setLayout(new BorderLayout());
    
    m_resTable=new ResourceTalkTablePanel(engine);
    
    add(m_resTable, BorderLayout.CENTER);   
  }
 
  //public void response(List<AttributeObject> paint)
  public void response(RethorAnswer answer)
  {
    if (answer==null)
    {
      throw new NullPointerException("answer");
    }
    
    if (answer.hasMineOutput())
    {
      m_resTable.setResources(answer.getResources());
    }
    else
    {
      m_resTable.setResources(null);
    }
  }
   
}
